<?php
require 'header.php';
echo '<div class="panel-body">';
if (! $_POST ['p']) {
	echo '<form method="post"><div class="input-group col-xs-4 divcenter">
  		<span class="input-group-addon"><i class="icon icon-user"></i></span>
  		<input type="text" class="form-control input-lg" placeholder="昵称--必填" name="pname"><br/><br/>
		</div>
		<div class="input-group col-xs-4 divcenter">
  		<span class="input-group-addon"><i class="icon icon-envelope"></i></span>
  		<input type="text" class="form-control input-lg" placeholder="邮箱--可空" name="pmail"><br/><br/>
		</div>
		<div class="input-group col-xs-4 divcenter">
  		<span class="input-group-addon"><i class="icon icon-chat-dot"></i></span>
  		<textarea class="form-control" rows="3" placeholder="内容--必填" name="pcontent"></textarea>
		</div><br/>
		<div class="divcenter"><input class="btn btn-danger" type="submit" value="评论" name="p"></div></form>';
} else {
	if (! $_POST ['pname'] || ! $_POST ['pcontent']) {
		echo '请按要求填写评论';
	} else {
		require './config/connect.php';
		$psql = "INSERT INTO comment(zid,pname,pmail,pcontent,times) VALUES ('" . $_GET [zid] . "','" . $_POST [pname] . "','" . $_POST [pmail] . "','" .  $_POST [pcontent] . "',NOW());";
		$_mysqli->query ( $psql );
		echo '留言成功!请点击右上角退出当前状态';
	}
}
require 'footer.php';
?>